<?php
use yii\bootstrap\Html;
use kartik\detail\DetailView;
use igorvolnyi\widgets\modal\ModalAjaxMultiple;
use yii\helpers\Url;
/**
 * @var \yii\web\View $this
 * @var \common\models\db\User $user
 */
$user = Yii::$app->user->identity;
$this->title = "个人中心";
?>

<div class="user-center-index">
    <div class="row">
        <div class="col-sm-3 col-md-3 col-lg-2">
            <div class="panel panel-default">
                <div class="panel-body">
                    <div>
                        <div class="text-center">
                            <?php echo Html::img($user->avatar, ['class' => "img img-responsive", 'alt' => "修改头像"]) ?>
                        </div>
                        <hr>
                        <div class="row">
                            <div class="col-xs-6">
                                <span class="text-muted">
                                    <?php
                                    echo ModalAjaxMultiple::widget([
                                        'header' => '修改密码',
                                        'toggleButton' => [
                                            'label' => '修改密码',
                                            'class' => 'btn btn-xs btn-warning'
                                        ],
                                        'url' => Url::to(['/user/center/update-password']), // Ajax view with form to load
                                        'ajaxSubmit' => true, // Submit the contained form as ajax, true by default
                                        'options' => ['class' => 'header-primary'],
                                        'autoClose' => true,
                                    ]);
                                    ?>
                                </span>
                                <span class="text-muted">
                                    <?php
                                    echo ModalAjaxMultiple::widget([
                                        'header' => '设置支付密码',
                                        'toggleButton' => [
                                            'label' => '设置支付密码',
                                            'class' => 'btn btn-xs btn-danger'
                                        ],
                                        'url' => Url::to(['/user/center/set-pay-password']), // Ajax view with form to load
                                        'ajaxSubmit' => true, // Submit the contained form as ajax, true by default
                                        'options' => ['class' => 'header-primary'],
                                        'autoClose' => true,
                                    ]);
                                    ?>
                                </span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-5 col-md-5 col-lg-5">
            <?= DetailView::widget([
                'model' => $user,
                'panel'=>[
                    'heading'=>"用户信息",
                    'type'=>DetailView::TYPE_DEFAULT,
                ],
                'enableEditMode' => false,
                'mode'=>DetailView::MODE_VIEW,
                'labelColOptions' => ['style' => 'width: 40%'],
                'attributes' => [
                    [
                        'attribute' => "username",
                    ],
                    [
                        'attribute' => "nickname",
                    ],
                    [
                        'label' => "手机号",
                        'value' => function ()use($user){
                            $html = "{$user->phone} ".ModalAjaxMultiple::widget([
                                    'header' => '设置手机号',
                                    'toggleButton' => [
                                        'label' => '设置手机号',
                                        'class' => 'btn btn-xs btn-danger'
                                    ],
                                    'url' => Url::to(['/user/center/set-phone']), // Ajax view with form to load
                                    'ajaxSubmit' => true, // Submit the contained form as ajax, true by default
                                    'options' => ['class' => 'header-primary'],
                                    'autoClose' => true,
                                ]);
                            return $html;
                        },
                        'format' => "raw",
                    ],
                    [
                        'label' => "邮箱",
                        'value' => function ()use($user){
                            $html = "{$user->email}";
                            return $html;
                        },
                        'format' => "raw",
                    ],
                    [
                        'label' => "添加时间",
                        'value' => date("Y-m-d H:i", $user->created_at),
                    ],
                ],
            ]) ?>
        </div>
        <div class="col-sm-4 col-md-4 col-lg-5">
            <?= DetailView::widget([
                'model' => $user,
                'panel'=>[
                    'heading'=>"总部",
                    'type'=>DetailView::TYPE_DEFAULT,
                ],
                'enableEditMode' => false,
                'mode'=>DetailView::MODE_VIEW,
                'labelColOptions' => ['style' => 'width: 40%'],
                'attributes' => [
                    [
                        'label' => "部门",
                        'value' => "运管部",
                        'format' => "raw",
                    ],
                    [
                        'label' => "部门联系人",
                        'value' => "王经理",
                        'format' => "raw",
                    ],
                    [
                        'label' => "电子信箱",
                        'value' => "andi@andijt.com",
                        'format' => "raw",
                    ],
                    [
                        'label' => "部门电话",
                        'value' => "0571-28120061-688",
                        'format' => "raw",
                    ],
                    [
                        'label' => "微信",
                        'value' => "97973015,97973016,97973017",
                        'format' => "raw",
                    ],
                    [
                        'label' => "QQ",
                        'value' => "97973015",
                        'format' => "raw",
                    ],
                    [
                        'label' => "网址",
                        'value' => "www.andijt.com",
                        'format' => "raw",
                    ],
                    [
                        'label' => "全国客服电话",
                        'value' => "0571-28120061",
                        'format' => "raw",
                    ],
                ],
            ]) ?>
        </div>
    </div>
</div>
